<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/12 0012
 * Time: 12:04
 */

namespace app\home\controller;


use app\model\model\Ad;
use app\model\model\Contact;
use app\model\model\Free_tags;
use app\model\model\Setup;
use app\model\model\Social;
use think\Request;

class Page extends Base
{
    //实例化
    protected $_Ad;
    protected $_Freetags;
    protected $_Page;
    protected $_Setup;
    protected $_Social;
    public function __construct(Request $request = null){
        parent::__construct($request);
        $this->_Ad = new Ad();
        $this->_Page = new \app\model\model\Page();
        $this->_Freetags = new Free_tags();
        $this->_Setup = new Setup();
        $this->_Social = new Social();
    }
    public function aboutus(){
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>11,'flag'=>1]);
        $this->assign('banner',$banner);
        //page
        $page = $this->_Page->getOne(7);
        $this->assign('data',$page);
        //下面的介绍
        //首页Banner下面介绍信息
        $com_intro['one'] = $this->_Freetags->getOne(26);
        $com_intro['two'] = $this->_Freetags->getOne(27);
        $com_intro['three'] = $this->_Freetags->getOne(28);
        $this->assign('com_intro',$com_intro);
        return $this->fetch();
    }
    public function ass(){
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>12,'flag'=>1]);
        $this->assign('banner',$banner);
        //page
        $page = $this->_Page->getOne(8);
        $this->assign('data',$page);
        return $this->fetch();
    }
    public function contactus(){
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>13,'flag'=>1]);
        $this->assign('banner',$banner);
        //page
        $page = $this->_Page->getOne(10);
        $this->assign('data',$page);
        //setup
        $setup = $this->_Setup->getOne(['id'=>1]);
        $this->assign('setup',$setup);
        //social
        $social = $this->_Social->getOne(['id'=>1]);
        $this->assign('soc',$social);
        return $this->fetch();
    }
    public function addcontactus(){
        $Contact = new Contact();
        $data = [
            'name'=>input('name'),
            'com'=>input('com'),
            'email'=>input('email'),
            'tel'=>input('tel'),
            'country'=>input('country'),
            'content'=>input('content'),
            'create_time'=>time(),
            'type'=>input('type'),
        ];

        $re = $Contact->add($data);
        if($re){
             $url = WEB_URL.'admin';
             $res = email_send(false,false,false,'欧锐激光--通知邮件',"<p>有一条新的用户询盘需要处理，请<a href=".$url.">登录后台</a>查看！</p><br><p>姓名:{$data['name']}</p><p>公司:{$data['com']}</p><p>邮箱:{$data['email']}</p><p>电话:{$data['tel']}</p><p>国家:{$data['country']}</p><p>留言内容:{$data['content']}</p>");
             if($res){
                return json_echo_msg(200,'留言成功，稍后我们会联系您!');
            }

        }
    }
    public function aaaa(){
        email_send('z289542272@163.com',false,false,'欧锐激光--通知邮件',"111111111111");
    }
    //FAQ
    public function faq(){
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>18,'flag'=>1]);
        $this->assign('banner',$banner);
        return $this->fetch();
    }
    //证明
    public function certification(){
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>21,'flag'=>1]);
        $this->assign('banner',$banner);
        $data = $this->_Page->getOne(11);
        $this->assign('data',$data);
        return $this->fetch('view');
    }
    //制造能力
    public function capacity(){
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>22,'flag'=>1]);
        $this->assign('banner',$banner);
        $data = $this->_Page->getOne(12);
        $this->assign('data',$data);
        return $this->fetch('view');
    }
    //车间
    public function Workshop(){
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>23,'flag'=>1]);
        $this->assign('banner',$banner);
        $data = $this->_Page->getOne(13);
        $this->assign('data',$data);
        return $this->fetch('view');
    }
    //仓库
    public function Warehouse(){
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>24,'flag'=>1]);
        $this->assign('banner',$banner);
        $data = $this->_Page->getOne(14);
        $this->assign('data',$data);
        return $this->fetch('view');
    }
    public function reviews(){
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>25,'flag'=>1]);
        $this->assign('banner',$banner);
        $data = $this->_Page->getOne(15);
        $this->assign('data',$data);
        return $this->fetch('view');
    }
    //隐私政策
    public function Policy(){
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>26,'flag'=>1]);
        $this->assign('banner',$banner);
        $data = $this->_Page->getOne(16);
        $this->assign('data',$data);
        return $this->fetch('view');
    }
}